package com.houger.ddd.common.utils;

import com.houger.ddd.datamanager.utils.BaseEnum;
import lombok.Getter;

/**
 * @author martin
 * @date 2020/11/25
 */
public enum StatusCode implements BaseEnum<Integer> {

  SUCCESS(200,"success"),
  ERROR(500,"system_error"),

  /**
   * 和参数相关的异常-1000x
   */
  INVALID_PARAM(-10000,"非法参数"),
  /**
   * 2000x后端服务异常
   */
  BACK_SERVICE_FAIL(-20000,"后端服务请求异常"),

  /**
   * 3000x
   */
  NOT_PERMISSION_ACCESS(-30000,"无权限访问"),
  /**
   * 未登录
   */
  NOT_LOGIN(-30001,"未登录"),

  /**
   * 4000x
   *
   */
  NOT_FOUND_USER_INFO(-40000,"没有找到用户信息"),
  NOT_IN_RUN(5001,"活动状态不是进行中"),
  NOT_FOUND_IN_DB(5002,"数据库未查到数据"),
  DO_NOT_REPEAT(5003,"请勿重复参与"),
  START_THAN_END(5003,"开始时间大于结束时间"),
  VERIFICATION_CODE_IS_INCORRECT(5005,"验证码不正确"),
  INSTANCE_NOT_IN_RUN(5006,"实例状态不是开启中"),
  TIME_OUT( 5007, "奖励领取超时"),
  LIMITED( 5007, "已达实例限制"),
  INSUFFICIENT_STOCK( 5008, "库存不足"),


  RESP_CODE_FLOW_LIMITING_EXCEPTION( 8001, "被限流"),
  RESP_CODE_DEGRADE_EXCEPTION( 8002, "服务降级，稍后再试"),
  RESP_CODE_AUTHORITY_EXCEPTION( 8003, "触发授权规则"),
  RESP_CODE_PARAM_FLOW_EXCEPTION( 8004, "触发熔断规则"),
  RESP_CODE_SYSTEM_BLOCK_EXCEPTION( 8005, "触发系统规则"),
  /**
   * 异常
   */
  DEFAULT_FAIL(-99999,"默认异常"),
  SERVICE_UNAVAILABLE(-55555,"服务不可用，请稍后再试");

  private Integer code;

  @Getter
  private String msg;

  StatusCode(Integer code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  @Override
  public Integer getCode() {
    return this.code;
  }

}
